#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import requests

from lj_tool import tool_cache


class ApiAiRemote:
    def __init__(self, uri) -> None:
        self.uri = uri
        pass

    def analyse(self, port, source, model):
        print(
            f"LJ - 调用AI[http://{self.uri}:{port}/vision]分析 - {source} - {model}")
        res = requests.get(f"http://{self.uri}:{port}/vision",
                           params={"source": source, "model": model})

        print(res.text)


@tool_cache.lj_wrapper_cache(key="action_ai_remote_init", expiration_seconds=60 * 10)
def init(uri):
    return ApiAiRemote(uri)
